<div class="sub-page">
    <h2>Checkout</h2>

    <div class="all-product">
        <?php
        if (isset($action) && $action !== null) {
            $form = $this->beginWidget('CActiveForm', array(
                'id' => 'customer-form',
                'action' => $action,
                'enableAjaxValidation' => false,
            ));
        } else {

            $form = $this->beginWidget('CActiveForm', array(
                'id' => 'customer-form',
                'enableAjaxValidation' => false,
            ));
        }
        CHtml::$errorContainerTag = 'span';
        $errorBillingAddress = $billingAddress->getErrors();
        $errorDeliveryAddress = $deliveryAddress->getErrors();
        ?>

        <div class="contact">
            <div class="ct-title">Billing Address</div>
            <div class="form-style marT20">
                <?php echo $form->hiddenField($customer, 'user_id', array('value' => $customer->user_id)); ?>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'firstname'); ?>
                    <?php echo $form->textField($billingAddress, 'firstname', array('size' => 45, 'maxlength' => 45)); ?>
                    <?php if(isset($errorBillingAddress['firstname'])){?>
                    <div class="red-text">
                        <label></label>
                        <?php echo $form->error($billingAddress, 'firstname'); ?>
                    </div>
    <?php } ?>
                </p>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'lastname'); ?>
                    <?php echo $form->textField($billingAddress, 'lastname', array('size' => 45, 'maxlength' => 45)); ?>
<?php if(isset($errorBillingAddress['lastname'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($billingAddress, 'lastname'); ?>
                        </div>
                <?php }?>
                </p>
                
                <p>
                    <?php echo $form->labelEx($billingAddress, 'country'); ?>
                    <select name="BillingAddress[country]" data-placeholder="Choose a Country" style="width:536px">
                            <option value="">--Country--</option>
                            <?php foreach($countryList as $country) {?>
                                    <option <?php if($country->country_id == $billingAddress['country']) echo 'selected=selected';?> value="<?php echo $country->country_id;?>"><?php echo $country->name?></option>
                            <?php }
                            ?>
                    </select>
                   <?php if(isset($errorBillingAddress['country'])){?>
	                    <div class="red-text">
	                        <label></label>
	                    <?php echo $form->error($billingAddress, 'country'); ?>
	                        </div>
	        		<?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'street'); ?>
                    <?php echo $form->textField($billingAddress, 'street', array('size' => 45, 'maxlength' => 45)); ?>
    <?php if(isset($errorBillingAddress['street'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($billingAddress, 'street'); ?>
                        </div>
        <?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'city'); ?>
                    <?php echo $form->textField($billingAddress, 'city', array('size' => 32, 'maxlength' => 45)); ?>
        <?php if(isset($errorBillingAddress['city'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($billingAddress, 'city'); ?>
                        </div>
            <?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'state'); ?>
                    <?php echo $form->textField($billingAddress, 'state', array('size' => 32, 'maxlength' => 45)); ?>
            <?php if(isset($errorBillingAddress['state'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($billingAddress, 'state'); ?>
                        </div>
                <?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'zipcode'); ?>
                    <?php echo $form->textField($billingAddress, 'zipcode', array('size' => 10, 'maxlength' => 45)); ?>
                <?php if(isset($errorBillingAddress['zipcode'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($billingAddress, 'zipcode'); ?>
                        </div>
                    <?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'email'); ?>
                    <?php echo $form->textField($billingAddress, 'email', array('type' => 'email')); ?>
                    <?php if(isset($errorBillingAddress['email'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($billingAddress, 'email'); ?>
                        </div>
                        <?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($billingAddress, 'phone'); ?>
                    <?php echo $form->textField($billingAddress, 'phone', array('type' => 'tel')); ?>
                        <?php if(isset($errorBillingAddress['phone'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($billingAddress, 'phone'); ?>
                        </div>
                            <?php }?>
                </p>

                <p>
                    <label>&nbsp;</label>
                    <span><input name="is_delivery_same_address" class="ck_deliver_address" type="checkbox" value="1">Deliver to a orther address</span>
                </p>
                <?php if (empty(Yii::app()->user->id)) { ?>
                    <p>
                        <label>&nbsp;</label>
                        <span><input name="is_create_account" class="is_create_account" type="checkbox" value="1"> Create an account? </span>
                        <br>
                        <label></label>
                        <strong class="massage-create-account">You will be created user and received email to update
                            password</strong>
                    </p>
                <?php } ?>
            </div>
        </div>
        <div class="contact" id="delivery-address-container">
            <div class="ct-title">Delivery Address</div>
            <div class="form-style marT20">
                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'firstname'); ?>
                    <?php echo $form->textField($deliveryAddress, 'firstname', array('size' => 45, 'maxlength' => 45)); ?>
                            <?php if(isset($errorDeliveryAddress['firstname'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'firstname'); ?>
                        </div>
                    <?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'lastname'); ?>
                    <?php echo $form->textField($deliveryAddress, 'lastname', array('size' => 45, 'maxlength' => 45)); ?>
                                <?php if(isset($errorDeliveryAddress['lastname'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'lastname'); ?>
                    </div>
                        <?php }?>
                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'country'); ?>
                    <select name="DeliveryAddress[country]" data-placeholder="Choose a Country" style="width:536px">
						<option value="">--Country--</option>
						<?php foreach($countryList as $country) {?>
							<option <?php if($country->country_id == $deliveryAddress['country']) echo 'selected=selected';?> value="<?php echo $country->country_id;?>"><?php echo $country->name?></option>
						<?php }
						?>
					</select>
                </p>
                
                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'street'); ?>
                    <?php echo $form->textField($deliveryAddress, 'street', array('size' => 45, 'maxlength' => 45)); ?>
                                <?php if(isset($errorDeliveryAddress['street'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'street'); ?>
                        </div>
                        <?php }?>
                </p>

                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'city'); ?>
                    <?php echo $form->textField($deliveryAddress, 'city', array('size' => 32, 'maxlength' => 45)); ?>
                                <?php if(isset($errorDeliveryAddress['city'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'city'); ?>
                        </div>
                        <?php } ?>
                </p>

                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'state'); ?>
                    <?php echo $form->textField($deliveryAddress, 'state', array('size' => 32, 'maxlength' => 45)); ?>
                                <?php if(isset($errorDeliveryAddress['state'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'state'); ?>
                        </div>
                        <?php } ?>
                </p>

                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'zipcode'); ?>
                    <?php echo $form->textField($deliveryAddress, 'zipcode', array('size' => 10, 'maxlength' => 45)); ?>
                                <?php if(isset($errorDeliveryAddress['zipcode'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'zipcode'); ?>
                        </div>
                        <?php } ?>
                </p>

                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'email'); ?>
                    <?php echo $form->textField($deliveryAddress, 'email', array('type' => 'email')); ?>
                                <?php if(isset($errorDeliveryAddress['email'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'email'); ?>
                        </div>
                        <?php } ?>
                </p>

                <p>
                    <?php echo $form->labelEx($deliveryAddress, 'phone'); ?>
                    <?php echo $form->textField($deliveryAddress, 'phone', array('type' => 'tel')); ?>
                                <?php if(isset($errorDeliveryAddress['phone'])){?>
                    <div class="red-text">
                        <label></label>
                    <?php echo $form->error($deliveryAddress, 'phone'); ?>
                        </div>
                        <?php } ?>
                </p>
            </div>
        </div>
        <div style="clear:both">&nbsp;</div>
        <div>
			<a class="red-button" href="javascript:void(0)" onclick="document.getElementById('customer-form').submit();">
				Save and Continue
			</a>
        </div>
        <?php $this->endWidget(); ?>
    </div>
</div>

</div>




